import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);


const routes = [
    {
        path:"/",
        name:"login",
        component: () =>import("../views/login.vue"),
        meta:{
            title:'管理控制台-用户登录'
        }
    },
    {
        path:"/about",
        name:"about",
        component: () =>import("../views/about.vue"),
        meta:{
            title:'管理控制台-关于我们'
        }
    },
    {
        path:"/home",
        name:"home",
        component: () =>import("../views/home.vue"),
        redirect:"/home/index",
        children:[
            {
                path:'/home/filter',
                name:'index',
                component:() => import("../views/filter.vue"),
                meta:{
                    title:'管理控制台-filter表配置'
                }
            },
            {
                path:'/home/nat',
                name:'index',
                component:() => import("../views/nat.vue"),
                meta:{
                    title:'管理控制台-nat表配置'
                }
            },
            {
                path:'/home/mangle',
                name:'index',
                component:() => import("../views/mangle.vue"),
                meta:{
                    title:'管理控制台-mangle表配置'
                }
            },
            {
                path:'/home/raw',
                name:'index',
                component:() => import("../views/raw.vue"),
                meta:{
                    title:'管理控制台-raw表配置'
                }
            },
            {
                path:'/home/index',
                name:'index',
                component:() => import("../views/about.vue"),
                meta:{
                    title:'管理控制台-iptables流程图'
                }
            },
        ]
    },
    
]

const router = new VueRouter({
    mode: "hash",
    // mode:"history",
    base: process.env.BASE_URL,
    routes,
});

router.beforeEach((to, from, next) => {
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next()
})
  
export default router;
